package com.example.zhangHuSheZhiServcie.zhangHuSheZhiShiXianLei;

import com.example.zhangHuSheZhiDao.ZhangHuSheZhiDao;
import com.example.zhangHuSheZhiPoJi.WenJianShangChuanJieGuo;
import com.example.zhangHuSheZhiPoJi.XiuGaiJieGuo;
import com.example.zhangHuSheZhiPoJi.ZhangHuSheZhiS;
import com.example.zhangHuSheZhiServcie.ZhangHuSheZhiSercice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

/**
 * @author 。
 * @version 1.0
 * Create by 2022/11/29 20:21
 * 账户设置service实现类
 */
@Service
public class ZhangHuSheZhiServciee implements ZhangHuSheZhiSercice {
    @Autowired
    private ZhangHuSheZhiDao kl;
    @Value("${file.AttachmentToTheOrder}")
    private String bvb;
    @Override
    public String GetAccount() {
        ZhangHuSheZhiS account = kl.getAccount(1);
        String account1 = account.getAccount();
        return account1;
    }

    @Override
    public WenJianShangChuanJieGuo ShangChan(MultipartFile file) {
        long size = file.getSize();
        String originalFilename = file.getOriginalFilename();
        int i = originalFilename.indexOf(".");
        String houzhui = originalFilename.substring(i);
        UUID uuid = UUID.randomUUID();
//        String jk = houzhui.substring(1);
        File file1 = new File(bvb + GetAccount()+"TX"+ ".jpg");
        try {
            file.transferTo(file1);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new  WenJianShangChuanJieGuo("上传成功") ;
    }

    @Override
    public ZhangHuSheZhiS getYongHuXinXi() {

        return kl.getYongHuXinXi(1);
    }

    @Override
    public XiuGaiJieGuo XiuGaiMingZi(String name) {
        XiuGaiJieGuo g = new XiuGaiJieGuo(kl.modifyName(name,1));
        return g;
    }

    @Override
    public XiuGaiJieGuo XiuGaiQianming(String freestyle) {
        XiuGaiJieGuo g = new XiuGaiJieGuo(kl.modifyPersonalSignature(freestyle,1));
        return g;
    }

    @Override
    public XiuGaiJieGuo XiuGaiHaoMa(long phone) {
        XiuGaiJieGuo g = new XiuGaiJieGuo(kl.modifyPhone(phone,1));
        return g;
    }

    @Override
    public XiuGaiJieGuo XiuGaiYouXiangDiZhi(String email) {
        XiuGaiJieGuo g = new XiuGaiJieGuo(kl.modifyEmail(email,1));
        return g;
    }

    @Override
    public XiuGaiJieGuo XiuGaiMiMa(String password) {
        XiuGaiJieGuo g = new XiuGaiJieGuo(kl.modifyPassword(password,1));
        return g;
    }
}
